package com.aiyige.page.my.order;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.aiyige.MyApp;
import com.aiyige.R;
import com.aiyige.base.api.JsonUtil;
import com.aiyige.model.Subject;
import com.aiyige.model.moment.entity.MajorCourse;

/**
 * Created by xiachao on 2018/4/28.
 */

//列表填充工具类
// 要改的地方太多了,没办法,只能用一个工具管理统一
//    统一修改
public class OrderActionUtils {

    /**
     * @param subject
     * @param tvCity
     * @param cityName
     * @param moreBackJson
     * @param tvContentCount
     * @param tvDateInfo
     */
    public void fillViews(String subject, View llCity, TextView tvCity, String cityName, String moreBackJson, TextView tvContentCount, TextView tvDateInfo, int mediaSummary) {
        if (TextUtils.isEmpty(subject) || TextUtils.isEmpty(moreBackJson)) {
            return;
        }
        //专业课程
        MajorCourse majorCourse;
        if (!TextUtils.isEmpty(cityName)) {
            llCity.setVisibility(View.VISIBLE);
            tvCity.setText(cityName);
        } else {
            llCity.setVisibility(View.INVISIBLE);
            tvCity.setVisibility(View.INVISIBLE);
        }
        // 专业课程
        if (subject.equals(Subject.major_course)) {
            majorCourse = JsonUtil.toObject(moreBackJson, MajorCourse.class);
            if (majorCourse != null) {
                tvContentCount.setVisibility(View.VISIBLE);
                tvContentCount.setVisibility(majorCourse.getClassCount() > 0 ? View.VISIBLE : View.INVISIBLE);
                tvContentCount.setText(majorCourse.getClassCount() + MyApp.getAppContext().getString(R.string.class_count));
                tvDateInfo.setVisibility(View.VISIBLE);
                tvDateInfo.setText(MyApp.getAppContext().getString(R.string.open_class_date_value, majorCourse.getStartClassTime()));
            }
        }
        // 教学视频
        if (Subject.video_course.equals(subject)) {
            llCity.setVisibility(View.INVISIBLE);
            tvDateInfo.setVisibility(View.INVISIBLE);
            tvContentCount.setVisibility(mediaSummary > 0 ? View.VISIBLE : View.INVISIBLE);
            tvContentCount.setText(MyApp.getAppContext().getString(R.string.content_count_value, mediaSummary + ""));
            tvContentCount.setVisibility(View.VISIBLE);
        }
    }



}
